#ifndef MSGPANELEDITOR_H
#define MSGPANELEDITOR_H

#include "headerinclude.h"

class MsgPanelEditor : public QDialog
{
    Q_OBJECT
public:
    explicit MsgPanelEditor(QWidget *parent = nullptr);
    ~MsgPanelEditor();
public:
    VOID Init();
    VOID CreatePanelByType(PanelType eType,EditType eEType =NOTTODO,const QList<QTableWidgetItem*>* pItems = nullptr);        //创建数据增删改面板

    VOID CreateSysEditorPanel(EditType eEType,const QList<QTableWidgetItem*>* pItems = nullptr);
    VOID CreateSubEditorPanel(EditType eEType,const QList<QTableWidgetItem*>* pItems = nullptr);
    VOID CreateSubDataEditorPanel(EditType eEType,const QList<QTableWidgetItem*>* pItems = nullptr);
    VOID CreateFindPanel();

    VOID UpdateFindProgerssBar(INT nCurProgerss,INT nMaxProgress,INT nFindNum);
    VOID UpdateFindItem();
    VOID ShowFindData();            //更新查找的结果到面板中显示


    inline QStringList GetMsgTypeList()
    {
        QStringList list;
        for(INT i = T_BOOL;i<= T_ARRAY;++i)
        {
            list<<GetDataInfoType((PROTOCOLDATATYPE)i);
        }
        return list;
    }

    inline QString GetDataInfoType(const PROTOCOLDATATYPE nTypeId)
    {
        switch (nTypeId)
        {
        case T_BOOL:
            return "bool";
        case T_CHAR:
            return "char";
        case T_UCHAR:
            return "unsinged char";
        case T_SHORT:
            return "short";
        case T_USHORT:
            return "unsinged chort";
        case T_INT:
            return "int";
        case T_UINT:
            return "unsinged int";
        case T_INT64:
            return "int64";
        case T_UINT64:
            return "unsinged int64";
        case T_FLOAT:
            return "float";
        case T_DOUBLE:
            return "double";
        case T_STRUCT:
            return "struct";
        case T_UNION:
            return "union";
        case T_STRING:
            return "string";
        case T_ARRAY:
            return "array";
        default:
            return "";
        }
    }


    //信号处理
signals:
    void sendFindOkBtnClick(QString,INT);               //查找面板OKButton
    void sendSysEditorBtnClick(INT,QString,EditType);
    void sendSubEditorBtnClick(INT,QString,INT,EditType);
    void sendSubDataEditorBtnClick(INT,QString,QString,EditType);
public slots:
    void onFindOkBtnClick(PanelType);
    void onFindCancelBtnClick();
private:

/*------------FindPanelUiDef----------------*/
    QStringList         m_PanelName;
    QDialog*            m_FindDialog;
    QLabel *            m_InptuLabel;
    QLineEdit *         m_LineEditor;
    QPushButton *       m_OkBtn;
    QCheckBox*          m_checkBox;
    QPushButton *       m_CancelBtn;
    QGridLayout *       m_GridLayout;
    QProgressBar *      m_ProgerssBar;
    QGroupBox*          m_QgroupBox;
    QGroupBox*          m_TreeBox;
/*------------FindItemPanelUiDef----------------*/
    QTreeWidget*       m_TreePanel;
/*------------CreateSysMsg----------------*/

    QLineEdit*          m_SysInput;
    QLineEdit*          m_SysInputData;
    QComboBox*          m_SubType;

    QLineEdit*          m_MsgInput;
    QLineEdit*          m_MsgInputData;
    QComboBox*          m_MsgBox;
    QTextEdit*          m_MsgDataEdit;
public:
    QVector<FINDDATA>       m_FindData;
    QString                 m_PanelString;
    EditType                m_EditType;
private:

};

#endif // MSGPANELEDITOR_H
